#import('../dart/zxcv-web.dart', prefix:'zxcv');

void main() {
  zxcv.start(new Sample(), '#game-screen');
}

class Sample extends zxcv.Game {
  zxcv.SpatialNode transform1;
  zxcv.SpatialNode transform2;
  zxcv.SpriteNode sprite;
  zxcv.Texture texture;
  
  void start(Map options) {
    transform1 = new zxcv.SpatialNode();
    transform1.transform = new zxcv.Transform2D();
    transform1.transform.translation.x = 200;
    transform1.transform.translation.y = 200;
    
    transform2 = new zxcv.SpatialNode();
    transform2.transform = new zxcv.Transform2D();
    //transform2.transform.scale = new zxcv.vec2(2,2);
    transform2.transform.translation.x = -30;
    transform2.transform.translation.y = -30;
    transform1.addChild(transform2);
    texture = new zxcv.Texture('knight1.png');
  }

  void update(double dt) {
    transform1.transform.rotation += dt;
    transform2.transform.rotation = -transform1.transform.rotation;
    transform1.updateTransform(new zxcv.TransformContext());
  }

  void draw(g) {
    g.pushTransform(transform1.transform.matrix);
    g.draw(texture, 15,19);
    g.pushTransform(transform2.transform.matrix);
    g.draw(texture, 15,19);
    g.popTransform();
    g.popTransform();
  }
}